﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace M
{
    public class UrlQuery
    {
        public static int? rootCategoryID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["rootCategoryID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? manufacturerID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["manufacturerID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? orderID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["orderID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static Guid? orderIdentity
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["orderIdentity"] + "";
                if (query == "") return null;
                return Guid.Parse(query);
            }
        }

        public static int? copyProductID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["CopyProductID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? propertyID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["PropertyID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? parentID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["ParentID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? productID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["productID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? userID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["UserID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? feedBackID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["FeedBackID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? newsID
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["NewsID"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static List<int> filters
        {
            get
            {
                List<int> ret = new List<int>();
                string query = HttpContext.Current.Request.QueryString["filters"] + "";
                if (query == "") return ret;
                foreach (string s in query.Split(','))
                    ret.Add(int.Parse(s));
                return ret;
            }
        }

        public static int? categoryID
        {
            get 
            {
                string query = HttpContext.Current.Request.QueryString["categoryID"] + "";
                if (query == "") return null;
                return int.Parse(query); 
            }
        }

        public static string sort
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["sort"] + "";
                return query;
            }
        }

        public static string search
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["search"] + "";
                return query;
            }
        }

        public static string q
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["q"] + "";
                return query;
            }
        }

        public static int? limit
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["limit"] + "";
                if (query == "") return null;
                return int.Parse(query);
            }
        }

        public static int? page
        {
            get
            {
                string query = HttpContext.Current.Request.QueryString["page"] + "";
                if (query == "") return null;
                return int.Parse(query); 
            }
        }
    }
}